﻿@using TomNet.IMSC.Model.DbModels.Common
@{
    Layout = null;
    var cid = Request.QueryString["cid"] != null ? Request.QueryString["cid"].ToString() : "-1";
    var Style = ViewData["Style"] as List<Dictionary>;//风格
    var HouseType = ViewData["HouseType"] as List<Dictionary>;//户型
    var Area = ViewData["Area"] as List<Dictionary>;//面积

}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link href="~/Content/Css/bootstrap.min.css?v=3.3.6&a=a" rel="stylesheet">
    <link href="~/Content/Css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="~/Content/Css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="~/Content/Css/animate.css" rel="stylesheet">
    <link href="~/Content/Css/style.css?v=4.1.0" rel="stylesheet">
    <title>Insert</title>
    <style>
    </style>
</head>
<body>
    <div class="wrapper wrapper-content animated fadeInRight">
        <form class="form-horizontal m-t" id="mainForm">
            <input type="hidden" name="DecorationCompanyID" id="DecorationCompanyID" value=@cid />
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">名称：</label>
                        <div class="col-xs-8">
                            <input id="Name" name="Name" type="text" class="form-control">
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">价格：</label>
                        <div class="col-xs-8">
                            <input id="ShowPrice" name="ShowPrice" type="text" class="form-control">
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">户型：</label>
                        <div class="col-xs-8">
                            <select class="form-control sel" id="HouseType" name="HouseType">
                            @foreach (var item in HouseType)
                            {
                                <option value=@item.Id>@item.Value</option>
                            }
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">面积：</label>
                        <div class="col-xs-8">
                            <input id="Area" name="Area" type="text" placeholder="㎡" class="form-control">
                        </div>
                    </div>
                </div>
            </div>


            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">面积标签：</label>
                        <div class="col-xs-8">
                            <select class="form-control sel" id="AreaTag" name="AreaTag">
                            @foreach (var item in Area)
                            {
                                <option value=@item.Id>@item.Value</option>
                            }
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">风格：</label>
                        <div class="col-xs-8">
                            <select class="form-control sel" id="Style" name="Style">
                            @foreach (var item in Style)
                            {
                                <option value=@item.Id>@item.Value</option>
                            }
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">工期：</label>
                        <div class="col-xs-8">
                            <input id="TimeLimit" name="TimeLimit" type="text" class="form-control">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">设计师：</label>
                        <div class="col-xs-8">
                            <input id="Designer" name="Designer" type="text" class="form-control">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">作品类型：</label>
                        <div class="col-xs-10">
                            <input id="OpusType" name="OpusType" type="text" class="form-control">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">

                </div>
                <div class="col-sm-6">
                    <div class="pull-right">
                        <button id="submit" class="btn btn-primary pull-center" type="submit">
                            <i class="fa fa-check"></i>&nbsp;提&nbsp;交
                        </button>
                    </div>
                </div>
            </div>
        </form>


    </div>
    <!-- 全局js -->
    <script type="text/javascript" src="~/Scripts/jquery.min.js?v=2.1.4"></script>
    <script type="text/javascript" src="~/Scripts/bootstrap.min.js?v=3.3.6"></script>

    <!-- jQuery Validation plugin javascript-->
    <script type="text/javascript" src="~/Scripts/plugins/validate/jquery.validate.min.js"></script>
    <script type="text/javascript" src="~/Scripts/plugins/validate/messages_zh.min.js"></script>
    <script type="text/javascript" src="~/Scripts/Extensions/ExtValidator.js"></script>

    <!-- layer javascript -->
    <script type="text/javascript" src="~/Scripts/plugins/layer/layer.min.js"></script>
    <script>
        $(function () {
            // validate signup form on keyup and submit
            var icon = "<i class='fa fa-times-circle'></i> ";
            var validator = $("#mainForm").validate({
                rules: {
                    Name: {
                        required: true,
                        maxlength: 50
                    }
                },
                messages: {
                    Name: {
                        required: icon + "请输入装修案例名称",
                        maxlength: icon + "案例名称过长"
                    }
                },
                submitHandler: function (form) {
                    //进行ajax传值
                    $.ajax({
                        url: "/Decoration/DecorationCompanyCase/InsertAsync",
                        type: "post",
                        dataType: "json",
                        data: $('#mainForm').serialize(),
                        success: function (data) {
                            //Info,Success,Warning,Error
                            var type = data.type;
                            if (type == 1) {
                                layer.msg(data.content, { icon: 6, time: 2000 },
                                    function () {
                                        var index = parent.layer.getFrameIndex(window.name);
                                        parent.layer.close(index);
                                    });

                            } else {
                                layer.msg(data.content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }
            });
        });
    </script>
</body>
</html>
